package com.heima.wemedia.controller.v1;


import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@Slf4j
@RequestMapping("/api/v1/material")
public class WmMaterialController {

    @Autowired
    private WmMaterialService materialService;

    //图片上传  MultipartFile  SpringMVC提供的文件上传的类型参数
    //前端请求表单数据：@RequestParam("multipartFile")  “”里面需要与前端保持一致，
    //如果后面已经一致了，可以不写
    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture (@RequestParam("multipartFile") MultipartFile multipartFile){
        return materialService.uploadPicture(multipartFile);
    }

    /**
     * 图片列表查询
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult findList(@RequestBody WmMaterialDto dto){
        return materialService.findList(dto);
    }

}
